package com.example.shop.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.shop.entity.Address;
import com.example.shop.service.AddressService;
import com.example.shop.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**

 *@ClassName AddressController

 *@Description TODO

 *@Author 吴

 *@Date 3.26

 */
@Controller
@RequestMapping("/address")
@Tag(name = "AddressController", description = "对Address操作的接口")
public class AddressController {

    @Autowired
    private AddressService addressService;

    /**
     * 通过ID查询单条数据
     *
     * @param addressid 主键
     * @return 实例对象
     */
    @GetMapping("/{addressid}")
    public Address queryById(@PathVariable Integer addressid) {
        return addressService.queryById(addressid);
    }

    /**
     * 新增数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
    @PostMapping
    public Address insert(@RequestBody Address address) {
        return addressService.insert(address);
    }

    /**
     * 修改数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
    @PutMapping
    public Address update(@RequestBody Address address) {
        return addressService.update(address);
    }

    /**
     * 通过主键删除数据
     *
     * @param addressid 主键
     * @return 是否成功
     */
    @DeleteMapping("/{addressid}")
    public boolean deleteById(@PathVariable Integer addressid) {
        return addressService.deleteById(addressid);
    }

}
